import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class NguessNumberTest {

    @Test
    public void random4() {
        NguessNumber s = new NguessNumber();
        int[] i = s.generateAnswer();
        assertEquals(i.length,4);
        for (int p=0;p<=3;p++){
            for (int j = p-1;j>=0;j--){
                assertNotEquals(i[j],i[p]);
            }
            assertTrue(i[p]>=0&&i[p]<=9);
        }

    }
    @Test
    public void getPlayerInput(){
        NguessNumber s = new NguessNumber();
         int[] i = s.getPlayerInput();
        assertEquals(i.length,4);
    }
    @Test
    public void compareGuessAnswer1(){
        NguessNumber s = new NguessNumber();
        s.s[0]=3;
        s.s[1]=8;
        s.s[2]=7;
        s.s[3]=6;
        s.guess[0]=1;
        s.guess[1]=8;
        s.guess[2]=7;
        s.guess[3]=6;
        String i = s.compareGuessAnswer();
        assertEquals(i,3+"A"+0+"B");

    }
    @Test
    public void compareGuessAnswer2(){
        NguessNumber s = new NguessNumber();
        s.s[0]=3;
        s.s[1]=8;
        s.s[2]=7;
        s.s[3]=6;
        s.guess[0]=1;
        s.guess[1]=6;
        s.guess[2]=7;
        s.guess[3]=2;
        String i = s.compareGuessAnswer();
        assertEquals(i,1+"A"+1+"B");

    }
    @Test
    public void compareGuessAnswer3(){
        NguessNumber s = new NguessNumber();
        s.s[0]=3;
        s.s[1]=6;
        s.s[2]=7;
        s.s[3]=6;
        s.guess[0]=1;
        s.guess[1]=11;
        s.guess[2]=7;
        s.guess[3]=2;
        String i  = s.compareGuessAnswer();
        assertEquals(i,"请输入0-9的整数而不是"+s.guess[1]);

    }
    @Test
    public void compareGuessAnswer4(){
        NguessNumber s = new NguessNumber();
        s.s[0]=3;
        s.s[1]=6;
        s.s[2]=7;
        s.s[3]=6;
        s.guess[0]=1;
        s.guess[1]=-11;
        s.guess[2]=7;
        s.guess[3]=2;
        String i = s.compareGuessAnswer();
        assertEquals(i,"请输入0-9的整数而不是"+s.guess[1]);

    }

    @Test
    public void isWin1(){
        NguessNumber s = new NguessNumber();
        s.s[0]=3;
        s.s[1]=8;
        s.s[2]=7;
        s.s[3]=6;
        s.guess[0]=3;
        s.guess[1]=8;
        s.guess[2]=7;
        s.guess[3]=6;
        s.compareGuessAnswer();
        boolean i = s.isWin();
        assertTrue(i);

    }
    @Test
    public void isWin2(){
        NguessNumber s = new NguessNumber();
        s.s[0]=3;
        s.s[1]=8;
        s.s[2]=7;
        s.s[3]=6;
        s.guess[0]=3;
        s.guess[1]=5;
        s.guess[2]=7;
        s.guess[3]=6;
        s.compareGuessAnswer();
        boolean i = s.isWin();
        assertFalse(i);

    }

    @Test
    public void main() {
    }
}